import 'package:flutter/material.dart';
import 'package:hrcapp/utils/theme_colors.dart';

class HRCDigitalCertificateScreen extends StatelessWidget {
  const HRCDigitalCertificateScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: const Color(0xFFF8F9FA), // 匹配SVG背景色
      appBar: AppBar(
        backgroundColor: Colors.white,
        elevation: 0,
        centerTitle: true,
        leading: IconButton(
          icon: const Icon(Icons.arrow_back_ios, size: 16, color: Colors.black),
          onPressed: () {
            Navigator.pop(context);
          },
        ),
        title: const Text(
          '数字权证',
          style: TextStyle(
            fontSize: 20,
            fontWeight: FontWeight.bold,
            color: Colors.black,
          ),
        ),
        actions: [
          Padding(
            padding: const EdgeInsets.only(right: 10),
            child: Container(
              width: 40,
              height: 40,
              decoration: const BoxDecoration(
                shape: BoxShape.circle,
                color: Color(0xFFE6F7FF),
              ),
              child: IconButton(
                icon: const Icon(Icons.share_outlined, size: 16, color: Color(0xFF1890FF)),
                onPressed: () {
                  // 分享按钮点击事件
                  ScaffoldMessenger.of(context).showSnackBar(
                    const SnackBar(content: Text('分享功能待实现')),
                  );
                },
              ),
            ),
          ),
        ],
      ),
      body: SingleChildScrollView(
        child: SafeArea(
          child: Padding(
            padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 20),
            child:
            Column(
              crossAxisAlignment: CrossAxisAlignment.center,
              children:
              [
                // 权证证书样式
                _buildCertificate(),
                const SizedBox(height: 30),

                // 操作按钮
                _buildVerifyButton(context),
                const SizedBox(height: 20),
                _buildDownloadButton(context),
                const SizedBox(height: 100),
              ],
            ),
          ),
        ),
      ),
    );
  }

  // 构建权证证书
  Widget _buildCertificate() {
    return Container(
      width: double.infinity,
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(16),
        boxShadow: [
          BoxShadow(
            color: Colors.black.withOpacity(0.1),
            spreadRadius: 0,
            blurRadius: 20,
            offset: const Offset(0, 4),
          ),
        ],
      ),
      child: Padding(
        padding: const EdgeInsets.all(10),
        child:
        Container(
          width: double.infinity,
          decoration: BoxDecoration(
            color: const Color(0xFFFFF7E6),
            borderRadius: BorderRadius.circular(12),
          ),
          child: Padding(
            padding: const EdgeInsets.all(20),
            child:
            Column(
              crossAxisAlignment: CrossAxisAlignment.center,
              children:
              [
                // 证书标题
                const Text(
                  '非遗资产数字权证',
                  style: TextStyle(
                    fontSize: 24,
                    fontWeight: FontWeight.bold,
                    color: Color(0xFFD48806),
                  ),
                ),
                const SizedBox(height: 40),

                // 证书内容
                const Text(
                  '兹证明',
                  style: TextStyle(
                    fontSize: 16,
                    color: Color(0xFF595959),
                  ),
                ),
                const SizedBox(height: 10),
                const Text(
                  '苏绣《牡丹图》',
                  style: TextStyle(
                    fontSize: 20,
                    fontWeight: FontWeight.bold,
                    color: Color(0xFF333333),
                  ),
                ),
                const SizedBox(height: 10),
                const Text(
                  '已完成数字化确权，拥有唯一数字标识',
                  style: TextStyle(
                    fontSize: 16,
                    color: Color(0xFF595959),
                  ),
                ),
                const SizedBox(height: 20),

                // 分割线
                Container(
                  width: double.infinity,
                  height: 1,
                  color: const Color(0xFFE5E6EB),
                ),
                const SizedBox(height: 30),

                // 权证信息
                Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children:
                  [
                    _buildCertificateInfo('权证编号', 'HRCC-2023-001'),
                    const SizedBox(height: 20),
                    _buildCertificateInfo('资产编号', 'HRC-NFT-2023-001'),
                    const SizedBox(height: 20),
                    _buildCertificateInfo('发行日期', '2023-09-15'),
                    const SizedBox(height: 20),
                    _buildCertificateInfo('有效期至', '永久'),
                    const SizedBox(height: 20),
                    _buildCertificateInfo('发行机构', '非遗数字认证中心'),
                  ],
                ),
                const SizedBox(height: 20),

                // 防伪二维码
                Container(
                  alignment: Alignment.centerRight,
                  child:
                  Container(
                    width: 60,
                    height: 60,
                    color: Colors.white,
                    child: const Center(
                      child:
                      SizedBox(
                        width: 50,
                        height: 50,
                        child: FittedBox(
                          fit: BoxFit.contain,
                          child: Icon(
                            Icons.qr_code,
                            color: Colors.black,
                          ),
                        ),
                      ),
                    ),
                  ),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }

  // 构建权证信息项
  Widget _buildCertificateInfo(String label, String value) {
    return Row(
      children:
      [
        SizedBox(
          width: 80,
          child:
          Text(
            label,
            style:
            const TextStyle(
              fontSize: 14,
              color: Color(0xFF666666),
            ),
          ),
        ),
        Expanded(
          child:
          Text(
            value,
            style:
            const TextStyle(
              fontSize: 14,
              fontWeight: FontWeight.bold,
              color: Color(0xFF333333),
            ),
          ),
        ),
      ],
    );
  }

  // 构建验证按钮
  Widget _buildVerifyButton(BuildContext context) {
    return Container(
      width: double.infinity,
      height: 50,
      decoration: BoxDecoration(
        color: const Color(0xFF1890FF), // 匹配SVG主色调
        borderRadius: BorderRadius.circular(25),
        boxShadow: [
          BoxShadow(
            color: const Color(0xFF1890FF).withOpacity(0.3),
            spreadRadius: 2,
            blurRadius: 5,
            offset: const Offset(0, 3),
          ),
        ],
      ),
      child: TextButton(
        onPressed: () {
          // 验证权证按钮点击事件
          ScaffoldMessenger.of(context).showSnackBar(
            const SnackBar(content: Text('验证权证功能待实现')),
          );
        },
        child:
          const Text(
            '验证此权证',
            style:
            TextStyle(
              fontSize: 18,
              fontWeight: FontWeight.bold,
              color: Colors.white,
            ),
          ),
      ),
    );
  }

  // 构建下载按钮
  Widget _buildDownloadButton(BuildContext context) {
    return Container(
      width: double.infinity,
      height: 50,
      decoration: BoxDecoration(
        color: const Color(0xFFF0F2F5),
        borderRadius: BorderRadius.circular(25),
      ),
      child: TextButton(
        onPressed: () {
          // 下载权证副本按钮点击事件
          ScaffoldMessenger.of(context).showSnackBar(
            const SnackBar(content: Text('下载权证副本功能待实现')),
          );
        },
        child:
          const Text(
            '下载权证副本',
            style:
            TextStyle(
              fontSize: 18,
              fontWeight: FontWeight.bold,
              color: Colors.black,
            ),
          ),
      ),
    );
  }
}